package com.shelpe.services.sinbad.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.shelpe.services.sinbad.model.AdgroupWithRptAdgroupDto;

import lombok.Data;

@Data
public class AdgroupAndRptAdgroupDto {
	@JsonProperty("camapaign_id")
	private long camapaignID;
	@JsonProperty("adgroup_id")
	private long adgroupID;
	@JsonProperty("img_url")
	private String imgUrl;
	private String title;
	@JsonProperty("drive_type")
	private String driveType;
	@JsonProperty("adgroup_status")
	private String adgroupStatus;// 1:推广 2:暂停 3:审核下线 4:下架

	private rptAdgroupVo pc;
	private rptAdgroupVo mobile;
	private rptAdgroupVo all;

	@Data
	public static class rptAdgroupVo {
		private int impressions;
		private int click;
		private int cost;
		private float cpc;
		private float ctr;
		private float cvr;
		private float roi;
		@JsonProperty("pay_count")
		private int payCount;
		private float sale;
		@JsonProperty("fav_count")
		private float favCount;
	}

	public void fromAdgroup(AdgroupWithRptAdgroupDto dto) {
		this.camapaignID = dto.getCamapaignId();
		this.adgroupID = dto.getAdgroupId();
		this.title = dto.getTitle();
		this.imgUrl = dto.getImgUrl();
		if (dto.getDriveType() == 1 || dto.getDriveType() == 2 || dto.getDriveType() == 4) {
			this.driveType = "auto";
		} else {
			this.driveType = "manual";
		}
		if (dto.getAdgroupStatus() == 4) {
			this.adgroupStatus = "online";
		} else if (dto.getAdgroupStatus() == 3) {
			this.adgroupStatus = "offline";
		} else if (dto.getAdgroupStatus() == 1) {
			this.adgroupStatus = "pro_offline";
		} else {
			this.adgroupStatus = "check_offline";
		}
	}
}
